//
//  UUID.m
//  GoBigMarket
//
//  Created by 李真 on 16/8/26.
//  Copyright © 2016年 legend. All rights reserved.
//

#import "UUID.h"
#import "KeyChainStore.h"

#define  KEY_USERNAME_PASSWORD @"com.lrkj.app.GDJusernamepassword"
#define  KEY_USERNAME @"com.lrkj.app.GDJusername"
#define  KEY_PASSWORD @"com.lrkj.app.GDJpassword"
static NSString *strUUID;
@implementation UUID

+(NSString *)getUUID
{
    strUUID = (NSString
                 *)[KeyChainStore
                    load:KEY_USERNAME_PASSWORD];
    //首次执行该方法时，uuid为空
    if ([strUUID isEqualToString:@""] || !strUUID)
    {
        //生成一个uuid的方法
        CFUUIDRef uuidRef =
        CFUUIDCreate(kCFAllocatorDefault);
        
        strUUID = (NSString *)CFBridgingRelease(CFUUIDCreateString (kCFAllocatorDefault,uuidRef));
        
        //将该uuid保存到keychain
        [KeyChainStore
         save:KEY_USERNAME_PASSWORD
         data:strUUID];
    }
    return strUUID;
}
+(void)delUUID{
    [KeyChainStore deleteKeyData:strUUID];
}

@end
